package server

import scala.actors._
import scala.collection.mutable._
import java.net._

/**
 * Server scheduler that keeps track of active clients
 * and assignments, and replies to requests for new assignments.
 * @author Jacob Biggs 
 * @param clientPool      Client pool to schedule
 * @param assignmentPool  Assignment Pool to schedule
 */
class Scheduler (clientPool : ClientPool, assignmentPool : AssignmentPool) extends Actor {
	
	def act()
	{
		// Start ClientPool and AssignmentPool actors
		clientPool.start()
		assignmentPool.start()
		
		loop
		{
			react
			{
				case message : messages.StatusMessage =>
					clientPool forward message
					
				case message : messages.RequestAssignment =>
					assignmentPool forward message
					
				case messages.toAssignmentPool(message) =>
					assignmentPool forward message
					
				case messages.toClientPool(message) =>
					clientPool forward message
			}
		}
		
	}
	
}